﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VioletDevelopmentLaboratory.Net.Web;
using VioletDevelopmentLaboratory.Net.Web.Component;

public partial class vboard_component_board_template_default_list_sub_button : BoardSubPartBase
{
	private String getListUrl()
	{
		return BoardParameters.Part != BoardPart.List ?
			BoardUtil.GetBoardUrl(BoardPart.List, BoardParameters.PageIndex, BoardParameters.CategoryID, "", BoardParameters.SearchText, 0, 0) :
			BoardUtil.GetBoardUrl(BoardPart.List, 0, "", "", "", 0, 0);
	}

	private String getThreadWriteUrl(out Boolean visible)
	{
		Boolean doWrite = base.CurrentUserInfo.IsAdministrator || base.CurrentUserInfo.IsSysop(base.CurrentBoard) || base.CurrentUserInfo.IsAuthorizedBy(base.CurrentBoard, BoardCommand.ThreadWrite);

		if (doWrite)
		{
			visible = true;
			return BoardUtil.GetBoardUrl(BoardPart.Form_Add, BoardParameters.PageIndex, BoardParameters.CategoryID, "", BoardParameters.SearchText, 0, 0);
		}

		visible = false;
		return String.Empty;
	}



	protected void Page_Load(object sender, EventArgs e)
	{
		//페이징 버튼
		PagerButton.PageSize = base.CurrentBoard.PageSize;
		PagerButton.ButtonCount = base.CurrentBoard.PageButtonCount;
		PagerButton.SelectCount = base.CurrentBoard.GetThreadCollectionCount(BoardParameters.CategoryID, Server.UrlDecode(BoardParameters.SearchText));

		//목록 링크
		ListHyperLink.NavigateUrl = this.getListUrl();

		//글쓰기 링크
		Boolean writeHyperLinkVisible = true;
		WriteHyperLink.NavigateUrl = this.getThreadWriteUrl(out writeHyperLinkVisible);
		WriteHyperLink.Visible = writeHyperLinkVisible;
	}
}
